import datetime
# 获取两个时间的月份
def get_month_range(start_day,end_day):
  months = (end_day.year - start_day.year)*12 + end_day.month - start_day.month
  month_range = ['%s-%s'%(start_day.year + mon//12,mon%12+1)
                    for mon in range(start_day.month-1,start_day.month + months)]
  return month_range

b = datetime.date.today().timetuple()
a = get_month_range(datetime.date(2021, 1, 1),datetime.date(b[0],b[1],b[2]))
a = a[:-1]
print(a)

